import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:testlzhu/common/routers/app_routers.dart';
import 'package:testlzhu/utils/index.dart';

import 'two_page_logic.dart';

class HomePageWidget extends StatelessWidget {
  const HomePageWidget({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    final controller = Get.put(TwoPageLogic());
    return Scaffold(
      backgroundColor: Colors.white,

      appBar: AppBar(
        elevation: 0,
        backgroundColor: Colors.white,
        title: topAppbar(controller),
      ),
      body: Container(
        margin: const EdgeInsets.symmetric(horizontal: 14),
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              mainAxisSize: MainAxisSize.max,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                GestureDetector(
                  onTap: (){
                    Get.toNamed(AppRoutes.equipment);
                  },
                  child: Column(
                    children: const [
                      Icon(Icons.message),
                      Text('机械设备'),
                    ],
                  ),
                ),
                Column(
                  children: const [
                    Icon(Icons.message),
                    Text('建筑材料'),
                  ],
                ),
                Column(
                  children: const [
                    Icon(Icons.message),
                    Text('采购大厅'),
                  ],
                ),
                Column(
                  children: const [
                    Icon(Icons.message),
                    Text('求职招聘'),
                  ],
                ),
                Column(
                  children: const [
                    Icon(Icons.message),
                    Text('智慧工地'),
                  ],
                ),
              ],
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {},
        child: const Icon(Icons.add),
      ),
    );
  }

  Widget topAppbar(TwoPageLogic logic) {
    return Row(
      children: [
        Padding(
          padding: const EdgeInsets.only(top: 40, bottom: 40),
          child: Container(
            width: 4,
            color: Colors.blue,
            child: const Text(''),
          ),
        ),
        Padding(
          padding: const EdgeInsets.only(top: 40, bottom: 40),
          child: Container(
            width: 4,
            color: Colors.blue.shade50,
            child: const Text(''),
          ),
        ),
        Container(
            margin: const EdgeInsets.only(left: 20),
            child: const Text(
              '阿达',
              style: TextStyle(color: Colors.red),
            )),
        const Expanded(child: Text('')),
        Container(
          width: 3,
          color: Colors.grey.shade300,
          child: const Text(''),
        ),
        GestureDetector(
          onTap: () {
            // logic.search();
          },
          child: Container(
            margin: const EdgeInsets.only(left: 10, right: 10),
            child: Image.asset(
              Util.getImgPath('ic_found_search', format: 'webp'),
              width: 22,
              height: 22,
            ),
          ),
        ),
        GestureDetector(
            onTap: () {
              // logic.scann();
            },
            child: Container(margin: const EdgeInsets.only(left: 15, right: 5), child: Util.getAssets('mine_scan_qr_code_v670', format: 'webp')))
      ],
    );
  }
}
